package cn.itcast.mobilebrowser.dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

import cn.itcast.mobilebrowser.model.History;

@Dao
public interface HistoryDao {

    @Insert
    void insert(History history);

    @Delete
    void deleteAll(History history);

    @Query("DELETE FROM history")
    void deleteAll();

    @Update
    void update(History history);

    @Query("SELECT * FROM history")
    LiveData<List<History>> getAllHistory();

    @Query("SELECT * FROM history " +
            "WHERE title LIKE '%' || :webTitle || '%'")
    LiveData<List<History>> getHistoryByTitle(String webTitle);
}
